<?php


if (!defined('IN_SEXMALL'))
{
	die('Hacking attempt');
}

/* 加载方法库、类 */
require(ROOT_PATH . 'includes/inc_constant.php');
require(ROOT_PATH . 'includes/lib_base.php');
require(ROOT_PATH . 'includes/lib_common.php');
require(ROOT_PATH . 'includes/lib_interface.php');
require(ROOT_PATH . 'includes/lib_main.php');
require(ROOT_PATH . 'includes/lib_insert.php');
require(ROOT_PATH . 'includes/lib_time.php');
require(ROOT_PATH . 'includes/lib_code.php');
require(ROOT_PATH . 'includes/MInterface.class.php');
require(ROOT_PATH . 'includes/MemcacheModel.class.php');
require(ROOT_PATH . 'includes/cls_mysql.php');


/* 对用户传入的变量进行转义操作。*/
if (!get_magic_quotes_gpc())
{
	if (!empty($_GET))
	{
		$_GET  = addslashes_deep(strip_tags_deep($_GET));
	}
	if (!empty($_POST))
	{
		$_POST = addslashes_deep(strip_tags_deep($_POST));
	}

	$_COOKIE   = addslashes_deep(strip_tags_deep($_COOKIE));
	$_REQUEST  = addslashes_deep(strip_tags_deep($_REQUEST));
}

/* 过滤$_SERVER系统变量 */
$temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));
if(strpos($temp, '<') !== false || strpos($temp, '"') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
	foreach ($_SERVER AS $key => $val){
		$_SERVER[$key] = htmlspecialchars(strip_tags(urldecode(urldecode($val))));
	}
}


/* 初始化用户session字串 */
include(ROOT_PATH . 'includes/cls_session.php');
$sess = new cls_session();
define('SESS_ID', $sess->get_session_id());


/* 创建DB对象 */
$db = new cls_mysql(DBHOST, DBUSER, DBPWD, DBNAME);


/* 读取配置 */
$_CFG = load_config();


// 常量配置文件
require(CONF_DIR . 'define.config.php');

/* 创建 Memcache 对象 */
ini_set("memcache.hash_strategy", "consistent");
$mem = new MemcacheModel($memServers);

/* 创建 接口对象 */
$mInterface = new MInterface($api_server);


define('UI', get_ui_version());


?>